package ArryProTest;

import java.util.Arrays;

//粗糙冒泡排序
public class BubbleSortTest {
    public static void main(String[] args) {
        int[] values = {12,3,23,43,42,21,3,478,6846,78468,478123,9,1};
        bubbleSort(values);
        System.out.println(Arrays.toString(values));
    }
    public static void bubbleSort(int[] values){
        int temp;
        //冒泡排序
        //遍历数组
        for (int i = 0; i < values.length; i++) {
            //循环减i减1
            for (int j = 0; j < values.length-1-i; j++) {
                //比较
                if (values[j] > values[j+1]) {
                    temp = values[j];
                    values[j] = values[j+1];
                    values[j+1] = temp;
                }

            }
        }
    }
}
